package com.huawei.appmarket.service.usercenter.personal.view.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.store.bean.user.GetPersonalInfoResBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import huawei.widget.HwTextView;
import o.azb;
import o.cgz;
import o.der.d;
import o.der.e;
import o.der.f;
import o.der.g;
import o.dof;
import o.ekg;
import o.eko;
import o.ekp;
import o.ekr;
import o.ekt;
import o.elf;
import o.ell;
import o.equ;
import o.evf;

public class PersonalInfoOverseaCard extends cgz implements OnClickListener {
    private TextView ʻ;
    private ImageView ʼ;
    private TextView ʽ;
    private LinearLayout ˊ;
    private TextView ˊॱ;
    private RelativeLayout ˋ;
    private ImageView ˎ;
    private LinearLayout ˏ;
    private ImageView ˏॱ;
    private PopupWindow ͺ;
    private ImageView ॱ;
    private LayoutInflater ॱˊ;
    private String ॱॱ;
    private ImageView ᐝ;

    static class c implements OnDismissListener {
        c() {
        }

        public void onDismiss() {
            ekg.ॱ().ॱ(false);
        }
    }

    public PersonalInfoOverseaCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ॱ(view);
        ʽ(view);
        ˎ();
        return this;
    }

    private void ॱ(View view) {
        azb.ʽ(view, d.ˑ);
        this.ˏ = (LinearLayout) view.findViewById(d.ͺॱ);
        this.ˋ = (RelativeLayout) view.findViewById(d.ˋˋ);
        this.ʻ = (TextView) view.findViewById(d.ˏˏ);
        this.ॱ = (ImageView) view.findViewById(d.ˍ);
        this.ˎ = (ImageView) view.findViewById(d.ˎˏ);
        this.ˊ = (LinearLayout) view.findViewById(d.ʼॱ);
        this.ʼ = (ImageView) view.findViewById(d.ˎˎ);
        this.ʽ = (TextView) view.findViewById(d.ˋᐝ);
        this.ˊॱ = (TextView) view.findViewById(d.ˊˊ);
        this.ˏॱ = (ImageView) view.findViewById(d.ʽॱ);
        this.ᐝ = (ImageView) view.findViewById(d.ˏˎ);
        ˋ();
    }

    private void ˎ() {
        this.ˏ.setOnClickListener(this);
        this.ˋ.setOnClickListener(this);
        this.ʼ.setOnClickListener(this);
        this.ᐝ.setOnClickListener(this);
        this.ˊ.setOnClickListener(this);
    }

    private void ˋ() {
        if (ekt.ˎ()) {
            this.ˏ.setVisibility(8);
            this.ˋ.setVisibility(0);
        } else {
            this.ˋ.setVisibility(8);
            this.ˏ.setVisibility(0);
        }
        evf.ˏ(this.ॱ, e.ॱˋ);
        evf.ˏ(this.ˎ, e.ॱˎ);
    }

    public void ˏ(CardBean cardBean) {
        ˋ();
        ʻ();
        ˊ();
        ʽ();
    }

    private void ˊ() {
        CharSequence userName = UserSession.getInstance().getUserName();
        if (!TextUtils.isEmpty(userName)) {
            this.ʽ.setText(userName);
        } else if (UserSession.getInstance().getStatus() == 3) {
            this.ʻ.setText(f.ʽʽ);
        } else {
            this.ʻ.setText(f.ˊʽ);
        }
    }

    private void ʽ() {
        int ॱॱ;
        GetPersonalInfoResBean ˊ = ekg.ॱ().ˊ();
        if (ekt.ˎ()) {
            CharSequence charSequence = "——";
            if (!(ˊ == null || dof.ˋ(ˊ.ᐝ()))) {
                charSequence = ˊ.ᐝ();
            }
            this.ˊॱ.setText(charSequence);
        }
        if (ˊ != null) {
            ॱॱ = ˊ.ॱॱ();
        } else {
            ॱॱ = 0;
        }
        ˊ(ॱॱ == 1, this.ˏॱ);
        ekr.ॱ(ekp.ॱ, Integer.valueOf(ॱॱ));
        ˎ(ˊ);
    }

    private void ˎ(GetPersonalInfoResBean getPersonalInfoResBean) {
        if (ekg.ॱ().ˋ() && getPersonalInfoResBean != null && getPersonalInfoResBean.ॱ() != null && !dof.ˋ(getPersonalInfoResBean.ॱ().ˋ())) {
            if (this.ॱˊ == null) {
                this.ॱˊ = LayoutInflater.from(this.ʼॱ);
            }
            LinearLayout linearLayout = (LinearLayout) this.ॱˊ.inflate(g.ʿ, null);
            if (linearLayout != null) {
                this.ˊॱ.measure(0, 0);
                int measuredWidth = this.ˊॱ.getMeasuredWidth();
                int measuredHeight = this.ˊॱ.getMeasuredHeight();
                if (this.ͺ == null) {
                    this.ͺ = new PopupWindow(linearLayout, -2, measuredHeight, false);
                }
                this.ͺ.showAsDropDown(this.ˊॱ, measuredWidth - 3, (-measuredHeight) - 24, 8388611);
                ((HwTextView) this.ͺ.getContentView().findViewById(d.ʼᐝ)).setText(getPersonalInfoResBean.ॱ().ˋ());
                this.ͺ.setOutsideTouchable(true);
                this.ͺ.setOnDismissListener(new c());
            }
        }
    }

    private void ˊ(boolean z, View view) {
        if (z) {
            view.setVisibility(0);
        } else {
            view.setVisibility(8);
        }
    }

    private void ʻ() {
        String ʼ = dof.ʼ(UserSession.getInstance().getHeadUrl());
        if (TextUtils.isEmpty(ʼ) || !ekt.ˎ()) {
            this.ʼ.setImageResource(e.ˉ);
            this.ॱॱ = null;
        } else if (!ʼ.equals(this.ॱॱ)) {
            equ.ˊ(this.ʼ, ʼ, "head_default_icon");
            this.ॱॱ = ʼ;
        }
    }

    public View ˉ() {
        return this.ˊˋ;
    }

    public void onClick(View view) {
        if (view.getId() == d.ͺॱ || view.getId() == d.ˎˎ || view.getId() == d.ˏˎ) {
            if (!UserSession.getInstance().isLoginSuccessful()) {
                this.ʽ.setText(f.ʽʽ);
            }
            ᐝ();
            new ell(ˉ().getContext()).ॱ();
        } else if (view.getId() == d.ʼॱ) {
            GetPersonalInfoResBean ˊ = ekg.ॱ().ˊ();
            if (ˊ != null) {
                ˊ.ˎ(0);
            }
            ˊ(false, this.ˏॱ);
            ʼ();
            new elf(ˉ().getContext()).ˊ();
        }
    }

    private void ᐝ() {
        if (ekt.ˎ()) {
            eko.ˎ(f.ˏˎ, KeyAndValue.NUMBER_01);
        } else {
            eko.ˎ(f.ﾞ, KeyAndValue.NUMBER_01);
        }
    }

    private void ʼ() {
        eko.ˋ(f.ᐝᐝ, KeyAndValue.NUMBER_01);
    }
}
